/**
 * @projectName study_java
 * @package Factory
 * @className Factory.Test
 */
package Factory;

import Factory.abstractFactory.IFood;
import Factory.abstractFactory.MechineFactory;
import Factory.abstractFactory.RealFactory;
import Factory.abstractFactory.ITraffic;
import Factory.method.CatFactory;
import Factory.method.DogFactory;
import Factory.simple.SimpleFactory;

import java.net.URL;

/**
 * Test
 * @description 测试类
 * @author answer_wx
 * @date 2022/6/29 16:40
 * @version 1.0
 */
public class Test {
    public static void main(String[] args) {
        System.out.println("------------简单工厂类---------");
        SimpleFactory simple = new SimpleFactory();
        /**
         * 多态
         */
        IAnimal cat = simple.createCat();
        IAnimal dog = simple.createDog();
        cat.eat();
        dog.eat();
        System.out.println("------------工厂方法类---------");
        /**
         * 猫工厂创建的猫对象
         */
        CatFactory catFactory = new CatFactory();
        IAnimal cat2 = catFactory.createAnimal();
        /**
         * 狗工厂创建的狗
         */
        DogFactory dogFactory = new DogFactory();
        IAnimal dog2 = dogFactory.createAnimal();
        cat2.eat();
        dog2.eat();
        System.out.println("------------抽象工厂类---------");
        /**
         * 创建抽象的工厂的具体工厂
         */
        /**
         * 分产品组
         */
        MechineFactory mechineFactory = new MechineFactory();
        IFood food = mechineFactory.createFood();
        IAnimal animal = mechineFactory.createAnimal();
        ITraffic traffic = mechineFactory.createTraffic();
        food.name();
        animal.eat();
        traffic.run();
        System.out.println("---------");
        RealFactory realFactory = new RealFactory();
        IFood food1 = realFactory.createFood();
        IAnimal animal1 = realFactory.createAnimal();
        ITraffic traffic1 = realFactory.createTraffic();
        food1.name();
        animal1.eat();
        traffic1.run();
    }
}